home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / UPC12BS1.ZIP / MAIL / RMAIL.C < prev    next >
C/C++ Source or Header  |  1993-09-20  |  42KB  |  1,040 lines

  1. /*--------------------------------------------------------------------*/
  2. /*       r m a i l . c                                                */
  3. /*                                                                    */
  4. /*       Delivery agent for UUPC/extended                             */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*    Changes Copyright (c) 1989 by Andrew H. Derbyshire.             */
  9. /*                                                                    */
  10. /*    Changes Copyright (c) 1990-1993 by Kendra Electronic            */
  11. /*    Wonderworks.                                                    */
  12. /*                                                                    */
  13. /*    All rights reserved except those explicitly granted by the      */
  14. /*    UUPC/extended license agreement.                                */
  15. /*--------------------------------------------------------------------*/
  16.  
  17. /*--------------------------------------------------------------------*/
  18. /*                          RCS Information                           */
  19. /*--------------------------------------------------------------------*/
  20.  
  21. /*
  22.  *    $Id: rmail.c 1.13 1993/09/20 04:39:51 ahd Exp $
  23.  *
  24.  *    $Log: rmail.c $
  25.  * Revision 1.13  1993/09/20  04:39:51  ahd
  26.  * OS/2 2.x support
  27.  *
  28.  * Revision 1.12  1993/07/31  16:22:16  ahd
  29.  * Changes in support of Robert Denny's Windows 3.x support
  30.  *
  31.  * Revision 1.11  1993/07/24  03:40:55  ahd
  32.  * Make usage() return code unique
  33.  *
  34.  * Revision 1.10  1993/06/13  14:06:00  ahd
  35.  * Save invoked program name and use it for recursive calls
  36.  *
  37.  * Revision 1.9  1993/05/09  03:41:47  ahd
  38.  * Don't use debuglevel -1, it suppresses important configuration errors
  39.  *
  40.  * Revision 1.8  1993/04/15  03:17:21  ahd
  41.  * Correct conditions under which name in userp structure used
  42.  *
  43.  * Revision 1.7  1993/04/13  02:26:30  ahd
  44.  * Make return codes more unique
  45.  *
  46.  * Revision 1.6  1993/04/11  00:33:05  ahd
  47.  * Global edits for year, TEXT, etc.
  48.  *
  49.  * Revision 1.5  1992/12/05  23:38:43  ahd
  50.  * Let logger close the log, not rmail
  51.  *
  52.  * Revision 1.4  1992/12/04  01:00:27  ahd
  53.  * Add copyright messages
  54.  *
  55.  */
  56.  
  57. /*--------------------------------------------------------------------*/
  58. /*    Function:   Stand alone mail delivery module for                */
  59. /*                UUPC/extended                                       */
  60. /*    Language:   Borland C++ 3.1 (ANSI C mode) or Microsoft C 6.0.   */
  61. /*    Arguments:  One or more addresses to deliver mail to            */
  62. /*                or "-t" to direct rmail to read the addresses       */
  63. /*                from the RFC-822 header.                            */
  64. /*                A third mode of operation is to specify '-w' and/   */
  65. /*                or '-s subject' followed by one or more addresses   */
  66. /*                with optional carbon copy flags (-c or -b) before   */
  67. /*                additional addresses.  This causes rmail to         */
  68. /*                function like a bare bones batch version of the     */
  69. /*                MAIL program; a valid RFC-822 header is generated   */
  70. /*                and the mail is delivered, aliases are not expanded */
  71. /*                and the mail is not locally logged.  (The current   */
  72. /*                user id as the from address is used unless the      */
  73. /*                environment variable LOGNAME is set, in which case  */
  74. /*                it is used.)                                        */
  75. /*                Optional argument "-f" to denote file to read in    */
  76. /*                place of stdin.                                     */
  77. /*                Optional argument "-F" to denote file to read in    */
  78. /*                place of stdin and DELETE after readering.          */
  79. /*                Optional argument "-x" to for debug level           */
  80. /*    Input:      mail to be delivered, with RFC-822 header, on       */
  81. /*                stdin.                                              */
  82. /*    Output:     'From' and 'Received:' headers are added,           */
  83. /*                'Bcc:' headers are removed, and the mail is         */
  84. /*                delivered to one or more local users and/or         */
  85. /*                one or more remote users.                           */
  86. /*    Exit code:  0  Success                                          */
  87. /*                1  One or more letters not delivered                */
  88. /*                2  No mail delivered                                */
  89. /*                3 Configuration file error                          */
  90. /*                4 Invalid option/help specified                     */
  91. /*                5 Input/output error                                */
  92. /*                6 Input/output error                                */
  93. /*                7 Input/output error                                */
  94. /*                                                                    */
  95. /*    Note:       When parsing RFC-822 headers, this program          */
  96. /*                expects them to be "well-behaved", that is in       */
  97. /*                format generated by UUPC/extended.  This implies:   */
  98. /*                                                                    */
  99. /*                      One address per line                          */
  100. /*                                                                    */
  101. /*                      Resent- headers, if any, before the original  */
  102. /*                      headers.                                      */
  103. /*                                                                    */
  104. /*                      From: header must precede To: header.         */
  105. /*                                                                    */
  106. /*                      To: header must precede Cc: and Bcc: headers. */
  107. /*                                                                    */
  108. /*                      Cc: and Bcc: headers must be together (one    */
  109. /*                      after the other)                              */
  110. /*                                                                    */
  111. /*                      The MUA has prefixed any obsolete Resent-     */
  112. /*                      headers by X-                                 */
  113. /*                                                                    */
  114. /*    Note:       The "-t" flag is supported by BSD sendmail for the  */
  115. /*                purpose listed above, but we also turn use it to    */
  116. /*                control other special options, all of which         */
  117. /*                basically cause the program to act more like a      */
  118. /*                local mailer than a remote mailer; these options    */
  119. /*                include:                                            */
  120. /*                                                                    */
  121. /*                      Stripping off blind carbon copies             */
  122. /*                                                                    */
  123. /*                      Generating the UUCP From line differently     */
  124. /*--------------------------------------------------------------------*/
  125.  
  126. /*--------------------------------------------------------------------*/
  127. /*                        System include files                        */
  128. /*--------------------------------------------------------------------*/
  129.  
  130. #include <stdio.h>
  131. #include <ctype.h>
  132. #include <io.h>
  133. #include <stdlib.h>
  134. #include <string.h>
  135. #include <time.h>
  136. #include <signal.h>
  137.  
  138. #ifdef _Windows
  139. #include <windows.h>
  140. #endif
  141.  
  142. /*--------------------------------------------------------------------*/
  143. /*                     Application include files                      */
  144. /*--------------------------------------------------------------------*/
  145.  
  146. #include "lib.h"
  147. #include "address.h"
  148. #include "arpadate.h"
  149. #include "deliver.h"
  150. #include "getopt.h"
  151. #include "hlib.h"
  152. #include "hostable.h"
  153. #include "logger.h"
  154. #include "security.h"
  155. #include "usertabl.h"
  156. #include